# -*- coding: utf-8 -*-
'''
肯德基餐厅位置查询
'''
import requests
url = 'https://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=keyword'
proxies = {"http": None, "https": None}
headers = {
    'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Mobile Safari/537.36'
}
for page in range(1,9):
    data = {
        'cname': '',
        'pid': '',
        'keyword': '北京',
        'pageIndex': str(page),
        'pageSize': '10'
    }

    response = requests.post(url=url, headers=headers, data=data, proxies=proxies)
    page_text = response.json()
    for dic in page_text['Table1']:
        storeName = dic['storeName']
        addr = dic['addressDetail']
        print('店名：', storeName, '\n地址：', addr)